In [ ]:
from matplotlib import pyplot as plt
%matplotlib inline

Load Parameters


In [ ]:
from utils_io import read_json

params = read_json('parameters.json')
RESIZE_X = params['resize']['x']
RESIZE_Y = params['resize']['y']
ITEM_FOLDER = params['item_folder']

Input Data

  • Image of the bin
  • List of items in the bin

In [ ]:
bin_stamp = '170405145336'
contents = ["Colgate_Toothbrush_4PK","Epsom_Salts","Duct_Tape",
            "Bath_Sponge","Crayons","Burts_Bees_Baby_Wipes"]

In [ ]:
bin_stamp = '170405145538'
contents = ["glue_sticks","tissue_box","laugh_out_loud_jokes",
            "toilet_brush","expo_eraser","table_cloth"]

In [ ]:
bin_stamp = '170508103814'
contents = ["mouse_traps","composition_book","tennis_ball_container",
            "tissue_box"]

In [ ]:
bin_stamp = '170508105421'
contents = ["mouse_traps","composition_book","tennis_ball_container",
            "tissue_box"]

In [ ]:
bin_stamp = '170508105808'
contents = ["laugh_out_loud_jokes","reynolds_wrap","robots_dvd",
            "hanes_socks", "flashlight"]

In [ ]:
items = [s.lower() for s in contents]

Compute Features in Bin


In [ ]:
from utils_io import imread_rgb
from utils_sift import compute_sift

filename_bin = 'bin/' + bin_stamp + '.png'
image_bin = imread_rgb(filename_bin)
(kp_bin, des_bin) = compute_sift(image_bin)

Match Bin and Items Features


In [ ]:
from utils_sift import match_items

item_d, recognised_items, mask_items = match_items(image_bin, kp_bin, des_bin, items)

Mask recognised items


In [ ]:
plt.imshow(mask_items,cmap='gray'), plt.axis('off');

Save mask and recognised items data (names and coordinates)


In [ ]:
from utils_io import imwrite

filename_mask = 'bin/' + bin_stamp + '_item_mask.pgm'
imwrite(filename_mask, mask_items)

In [ ]:
from utils_io import write_json

filename_items = 'bin/' + bin_stamp + '_items.json'
serial_data = [(name, proj.tolist()) for name, proj in recognised_items]
write_json(filename_items, serial_data)

In [ ]: